package com.ht.controller;

import com.ht.data.Result;
import com.ht.service.DoctorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("doctor")
@Api
@RefreshScope //开启自动刷新配置
public class DoctorController {

    @Autowired
    private DoctorService doctorService;

    /**
     * 根据医生id修改医生审核状态
     * @param doctorId 医生id
     * @param auditStatus 状态
     * @return
     */
    @ApiOperation("根据医生id修改医生审核状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "doctorId",value = "医生id",required = true,paramType = "path",dataTypeClass = Long.class),
            @ApiImplicitParam(name = "auditStatus",value = "医生审核状态1通过,2:不通过",required = true,paramType = "query",dataTypeClass = Integer.class)
    })
    @PutMapping("/{doctorId}")
    public Result updateDoctorAuditStatusByDoctorId(@PathVariable("doctorId")Long doctorId,@RequestParam("auditStatus") Integer auditStatus){
        int i = doctorService.updateDoctorAuditStatusByDoctorId(doctorId,auditStatus);
        if (i <= 0){
            return Result.ERROR();
        }
        return Result.OK();
    }
}
